//
//  ST_BTAccountAdditionalAttribute.swift
//  btvideo
//
//  Created by Jason on 2021/11/8.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyJSON


class ST_BTAccountAdditionalAttribute {
    /// 是否调研
    let needSurvey:Bool
    /// 女性未真人认证限制
    let faceRestricted:Bool?
    /// 已经邀请人数
    let countOfInvited:Int
    /// 已经通过审核的特质数
    let countOfMyPeculiarityPassed:Int
    /// 屏蔽手机联系人
    var ignoreMyContacts:Bool
    /// 能否上传封面
    let canUploadRoomCover:Bool
    
    var voiceSignStatus:Int
    /// 当前封面
    let currentRoomCover:String?
    /// 只允许认证的人聊天  后台字段 only_face_talk
    var allowTalkFaceDetected:Bool
    ///允许系统打招呼
    var allowAutoSayHi:Bool
    /// 语音免费次数
    let countOfFreeVoice:Int
    /// 视频免费次数
    let countOfFreeVideo:Int
    /// 派对🎉免费次数
    var liveTalkFreeNumber:Int
    /// 允许会员聊天
    var allowMember:Bool
    /// 允许点赞通知
    var allowThumbUpNotification:Bool
    /// 允许评论通知
    var allowRemarkNotification:Bool
    /// 允许收到喜欢通知
    var allowLoveNotification:Bool
    /// 微信
    var wechatNumber:String?
    ///免费搭讪次数
    var freeAccostTime:Int
    ///只允许文字聊天
    var onlyAllowTextTalk:Bool
    /// 匿名评论
    var anonymousRemark:Bool{
        didSet{
            NotificationCenter.default.post(name: Notification.Name.anonymousStatus, object: nil)
        }
    }
    /// 搜索需要VIP
    let searchNeedVip:Bool
    /// 已经绑定手机号
    var phoneBound:Bool
    /// 隐藏我的守护
    var myGuardHid:Bool
    /// 隐藏我的贵族
    var myNobilityHid:Bool
    
    /// 冻结用户  后台字段  is_freeze
    var youWereFrozen:Bool
    /// 冻结结束时间
    var frozeEndTime:String?
    /// 可滑动卡片
    var countOfSlideCard = 0
    /// 禁言 后台字段 block_state    1:正常 2:封号 3:禁言
    let mute:Int
    /// 数美服务封禁状态
    var SMForbidden:Bool? = nil
    
    /// 初印象次数
    var firstImpressionCount = 0
    
    var homeRecommendedHeaderVoiceStr = ""
    
    var homeRecommendedHeaderVideoStr = ""
    
    var homeRecommendedHeaderMatchStr = ""
    
    /// 是否是女神
    var isGoddess:Bool
    
    init(data:JSON,roomConfigData:JSON){
        
        self.firstImpressionCount = roomConfigData["free_count"].intValue
        self.homeRecommendedHeaderVoiceStr = roomConfigData["voice_hint"].stringValue
        self.homeRecommendedHeaderVideoStr = roomConfigData["video_hint"].stringValue
        self.homeRecommendedHeaderMatchStr = roomConfigData["match_hint"].stringValue
        
        self.youWereFrozen = data["is_freeze"].boolValue
        
        self.isGoddess = data["is_goddess"].boolValue
        
        self.frozeEndTime = data["freeze_end_time"].stringValue
        
        self.needSurvey = data["need_survey"].intValue == 1
        
        self.faceRestricted = data["send_limit"].bool
        
        self.countOfInvited = data["invite_num"].intValue
        
        self.countOfMyPeculiarityPassed = data["feature_pass_count"].intValue
        
        self.voiceSignStatus = data["voice_sign_status"].intValue
        
        self.ignoreMyContacts = data["address_book_switch"].intValue == 1
        
        self.canUploadRoomCover = data["can_upload"].boolValue
        
        if let str = data["room_cover"].string,str.count > 1{
            self.currentRoomCover = str
        }else{
            self.currentRoomCover = nil
        }
        
        self.allowTalkFaceDetected = data["only_face_talk"].intValue == 1
        
        self.allowAutoSayHi = data["auto_send_msg"].intValue == 1
        
        self.countOfFreeVoice = data["voice_free_num"].intValue
        
        self.countOfFreeVideo = data["video_free_num"].intValue
        
        self.liveTalkFreeNumber = data["free_once"].intValue
        
        self.allowMember = data["only_vip_talk"].intValue == 1
        
        self.allowThumbUpNotification = data["switch_thumb_up"].intValue == 1
        
        self.allowRemarkNotification = data["switch_comment"].intValue == 1
        
        self.allowLoveNotification = data["switch_receive_like"].intValue == 1
        
        if let wechat = data["wechat"].string,wechat.count > 2{
            self.wechatNumber  = wechat
        }else{
            self.wechatNumber  = nil
        }
        
        self.freeAccostTime = data["free_chat_num"].intValue
        
        self.onlyAllowTextTalk = data["can_receive_source"].intValue != 1
        
        self.anonymousRemark = data["is_anonymous"].intValue == 1
        
        self.searchNeedVip = data["search_need_vip"].boolValue
     
        self.phoneBound = data["have_phone"].boolValue
        
        self.myGuardHid = data["guard_close"].intValue == 2
        
        self.myNobilityHid = data["nobility_close"].intValue == 2
        
        self.countOfSlideCard = data["card_num"].intValue
        
        self.mute = data["block_state"].intValue
        
    }
}


extension ST_BTAccountAdditionalAttribute{
    
    func updateImpressionData(json:JSON){
        
        self.firstImpressionCount = json["free_count"].intValue
        self.homeRecommendedHeaderVoiceStr = json["voice_hint"].stringValue
        self.homeRecommendedHeaderVideoStr = json["video_hint"].stringValue
        self.homeRecommendedHeaderMatchStr = json["match_hint"].stringValue
        
    }
    
}


